import { useI18n } from '@/hooks/web/useI18n'
import { reactive, UnwrapRef } from 'vue'
import { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { useValidator } from '@/hooks/web/useValidator'
import { ElIcon, ElImage, ElTag } from 'element-plus'
import UploadFile from '@/components/UploadFile/index.vue'

const { t } = useI18n()
import { Plus } from '@element-plus/icons-vue'
import { createImageViewer } from '@/components/ImageViewer'
import { useEnumeratePicker } from '@/utils'

const { required } = useValidator()

export default function (schemaConfig: any) {
  const computingUnitOption = schemaConfig.fieldEnum?.value.comput_unit || []
  const algorithmOption = schemaConfig.fieldEnum?.value.algorithm || []
  const comput_unitList = schemaConfig.fieldEnum?.value.comput_unit || []
  const categoryOption = schemaConfig?.categoryList?.value

  const crudSchemas = reactive<CrudSchema[]>([
    {
      field: 'selection',
      search: {
        hidden: true
      },
      form: {
        hidden: true
      },
      detail: {
        hidden: true
      },
      table: {
        type: 'selection'
      }
    },
    {
      field: 'id',
      label: t('product.id'),
      align: 'center',
      search: {
        hidden: true
      },
      form: {
        hidden: true
      },
      detail: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center'
      }
    },
    {
      field: 'cname',
      label: t('product.cname'),
      form: {
        component: 'Input',
        formItemProps: {
          rules: [required()]
        },
        colProps: {
          span: 12
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 300
      }
    },
    {
      field: 'abbr',
      label: t('product.abbr'),
      form: {
        component: 'Input',
        formItemProps: {
          rules: [required()]
        },
        colProps: {
          span: 12
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150
      }
    },
    {
      field: 'main_photo',
      label: '商品主图',
      search: {
        hidden: true
      },
      form: {
        formItemProps: {
          rules: [required()],
          slots: {
            default: (data: any) => (
              <div class="flex flex-col">
                <UploadFile
                  url={'/common/uploadFile'}
                  fileType={['png', 'jpg', 'jpeg', 'webp']}
                  params={{ directory: 2 }}
                  limit={1}
                  isSlot={true}
                  listType={'picture-card'}
                  fileListMap={data.main_photo_urls}
                  showFileList={true}
                  // @ts-ignore
                  uploadSuccessRes={({ fileList }: Record<string, any>) => {
                    const ids = fileList.map((item: any) =>
                      item.response ? item.response.data.id : item.id
                    )
                    schemaConfig.setValues({ main_photo: ids })
                  }}
                  // @ts-ignore
                  handleRemoveFile={(fileList: Record<string, any>) => {
                    const ids = fileList.map((item: any) =>
                      item.response ? item.response.data.id : item.id
                    )
                    schemaConfig.setValues({ main_photo: ids })
                  }}
                >
                  <ElIcon>
                    <Plus />
                  </ElIcon>
                </UploadFile>
                <div class="m-t-3 text-xs text-gray-800">最多上传 1 张图片</div>
              </div>
            )
          }
        }
      },
      detail: {
        slots: {
          default: (data: Record<string, any>) =>
            data.main_photo_urls
              ? data.main_photo_urls.map((item: any) => (
                  <ElImage
                    key={item.id}
                    src={item.url}
                    zoom-rate={1.2}
                    max-scale={7}
                    min-scale={2}
                    fit="cover"
                    class="photo_default m-r-4 cursor-pointer"
                    // @ts-ignore
                    onClick={() => {
                      const urlList = data.main_photo_urls.map((item: any) => item.url)
                      const index = data.main_photo_urls.findIndex((v: any) => v.id === item.id)
                      // @ts-ignore
                      createImageViewer({
                        urlList,
                        initialIndex: index
                      })
                    }}
                  />
                ))
              : null
        }
      },
      table: {
        hidden: true
      }
    },
    {
      field: 'photo',
      label: t('product.photo'),
      search: {
        hidden: true
      },
      form: {
        formItemProps: {
          slots: {
            default: (data: any) => (
              <div class="flex flex-col">
                <UploadFile
                  url={'/common/uploadFile'}
                  fileType={['png', 'jpg', 'jpeg']}
                  params={{ directory: 2 }}
                  limit={9}
                  isSlot={true}
                  listType={'picture-card'}
                  fileListMap={data.photo_urls}
                  showFileList={true}
                  // @ts-ignore
                  uploadSuccessRes={({ fileList }: Record<string, any>) => {
                    const ids = fileList.map((item: any) =>
                      item.response ? item.response.data.id : item.id
                    )
                    schemaConfig.setValues({ photo: ids })
                  }}
                  // @ts-ignore
                  handleRemoveFile={(fileList: Record<string, any>) => {
                    const ids = fileList.map((item: any) =>
                      item.response ? item.response.data.id : item.id
                    )
                    schemaConfig.setValues({ ...data, photo: ids })
                  }}
                >
                  <ElIcon>
                    <Plus />
                  </ElIcon>
                </UploadFile>
                <div class="m-t-3 text-xs text-gray-800">最多上传 9 张图片</div>
              </div>
            )
          }
        }
      },
      detail: {
        slots: {
          default: (data: Record<string, any>) =>
            data.photo_urls
              ? data.photo_urls.map((item: any) => (
                  <ElImage
                    key={item.id}
                    src={item.url}
                    zoom-rate={1.2}
                    max-scale={7}
                    min-scale={2}
                    fit="cover"
                    class="photo_default m-r-4 cursor-pointer"
                    // @ts-ignore
                    onClick={() => {
                      const urlList = data.photo_urls.map((item: any) => item.url)
                      const index = data.photo_urls.findIndex((v: any) => v.id === item.id)
                      // @ts-ignore
                      createImageViewer({
                        urlList,
                        initialIndex: index
                      })
                    }}
                  />
                ))
              : null
        }
      },
      table: {
        hidden: true
      }
    },
    {
      field: 'sku',
      label: t('product.sku'),
      form: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 220
      }
    },
    {
      field: 'code',
      label: t('product.code'),
      form: {
        component: 'Input',
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 220
      }
    },
    {
      field: 'category',
      label: t('product.category'),
      search: {
        hidden: true
      },
      form: {
        component: 'TreeSelect',
        componentProps: {
          data: categoryOption,
          checkStrictly: true,
          filterable: true
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150,
        slots: {
          default: (data: any) => {
            return data.row.category_value
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.category_value
          }
        }
      }
    },
    {
      field: 'brand',
      label: t('product.brand'),
      search: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.brand,
          multiple: false,
          filterable: true
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.brand
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150,
        slots: {
          default: (data: any) => {
            return data.row.brand_value
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.brand_value
          }
        }
      }
    },
    {
      field: 'color_specs',
      label: t('product.color_specs'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        width: 150,
        align: 'center'
      }
    },
    {
      field: 'condition',
      label: t('product.condition'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: t('product.conditionValue.1'),
              value: '1'
            },
            {
              label: t('product.conditionValue.0'),
              value: '0'
            }
          ]
        },
        formItemProps: {
          rules: [required()]
        },
        value: '0'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120,
        slots: {
          default: (data: any) => {
            return data.row.condition_text
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.condition_text || ''
          }
        }
      }
    },
    {
      field: 'expiration_date',
      label: t('product.expiration_date'),
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber'
      },
      table: {
        hidden: true
      }
    },
    {
      field: 'memory_size',
      label: t('product.memory_size'),
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    {
      field: 'chip_number',
      label: t('product.chip_number'),
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    {
      field: 'working_mode',
      label: t('product.working_mode'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'algorithm',
      label: t('product.algorithm'),
      search: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.algorithm,
          multiple: false,
          filterable: true
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          multiple: true,
          clearable: true,
          filterable: true,
          options: algorithmOption
        },
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150,
        slots: {
          default: (data: any) => {
            return Array.isArray(data.row.algorithm_text) ? data.row.algorithm_text.join(' ,') : ''
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.algorithm_text.join(' ,')
          }
        }
      }
    },
    {
      field: 'model_id',
      label: t('product.model'),
      search: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.model,
          multiple: false,
          filterable: true
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.model,
          multiple: false,
          clearable: true,
          filterable: true
        },
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150,
        slots: {
          default: (data: any) => {
            return <span>{data.row.model_value}</span>
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return <span>{data.model_value}</span>
          }
        }
      }
    },
    {
      field: 'hashrate',
      label: t('product.hashrate'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input',
        formItemProps: {
          rules: [required()]
        },
        componentProps: {
          type: 'number'
        }
      },
      table: {
        headerAlign: 'center',
        width: 120,
        align: 'center'
      }
    },
    {
      field: 'computing_unit',
      label: t('product.computing_unit'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        componentProps: {
          options: computingUnitOption
        },
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100,
        slots: {
          default: (data: any) => {
            return <span>{useEnumeratePicker(comput_unitList, data.row.computing_unit)}</span>
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return <span>{useEnumeratePicker(comput_unitList, data.computing_unit)}</span>
          }
        }
      }
    },
    {
      field: 'power',
      label: t('product.power') + '(W)',
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    {
      field: 'working_voltage',
      label: t('product.working_voltage'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'noise_level',
      label: t('product.noise_level'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'network_conn_method',
      label: t('product.network_conn_method'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'operation_temperature',
      label: t('product.operation_temperature'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'working_humidity',
      label: t('product.working_humidity'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'colling_method',
      label: t('product.colling_method'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'weight',
      label: t('attachment.weight'),
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    {
      field: 'gross_weight',
      label: t('product.gross_weight'),
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    // 添加长宽高三个独立字段
    {
      field: 'package_length',
      label: '包装长度(mm)',
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        componentProps: {
          min: 0,
          precision: 2,
          step: 0.01,
          controlsPosition: 'right',
          placeholder: '长度'
        },
        colProps: { span: 8 },
        formItemProps: {
          rules: [{ required: true, message: '长度不能为空', trigger: 'blur' }]
        },
        value: (data) => {
          if (data.package_size) {
            const sizes = data.package_size.split('*')
            return sizes[0] || ''
          }
          return ''
        }
      },
      table: {
        hidden: true
      },
      detail: {
        hidden: true
      }
    },
    {
      field: 'package_width',
      label: '包装宽度(mm)',
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        componentProps: {
          min: 0,
          precision: 2,
          step: 0.01,
          controlsPosition: 'right',
          placeholder: '宽度'
        },
        colProps: { span: 8 },
        formItemProps: {
          rules: [{ required: true, message: '宽度不能为空', trigger: 'blur' }]
        },
        value: (data) => {
          if (data.package_size) {
            const sizes = data.package_size.split('*')
            console.log(sizes, 111111)
            return sizes[1] || ''
          }
          return ''
        }
      },
      table: {
        hidden: true
      },
      detail: {
        hidden: true
      }
    },
    {
      field: 'package_height',
      label: '包装高度(mm)',
      search: {
        hidden: true
      },
      form: {
        component: 'InputNumber',
        componentProps: {
          min: 0,
          precision: 2,
          step: 0.01,
          controlsPosition: 'right',
          placeholder: '高度'
        },
        colProps: { span: 8 },
        formItemProps: {
          rules: [{ required: true, message: '高度不能为空', trigger: 'blur' }]
        },
        value: (data) => {
          if (data.package_size) {
            const sizes = data.package_size.split('*')
            return sizes[2] || ''
          }
          return ''
        }
      },
      table: {
        hidden: true
      },
      detail: {
        hidden: true
      }
    },
    {
      field: 'billing_weight',
      label: t('product.billing_weight'),
      search: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: '已编辑',
              value: 1
            },
            {
              label: '未编辑',
              value: 0
            }
          ]
        }
      },
      form: {
        component: 'InputNumber'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 100
      }
    },
    {
      field: 'bare_macheine_size',
      label: t('product.bare_macheine_size'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },

    // 修改package_size字段
    {
      field: 'package_size',
      label: t('product.package_size'),
      search: {
        hidden: true
      },
      form: {
        hidden: true // 隐藏原始输入框
      },
      detail: {
        slots: {
          default: (data: any) => {
            if (data.package_size) {
              const [length, width, height] = data.package_size.split('*')
              return (
                <div class="flex space-x-2">
                  <div>长: {length}mm</div>
                  <div>宽: {width}mm</div>
                  <div>高: {height}mm</div>
                </div>
              )
            }
            return null
          }
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120,
        slots: {
          default: (data: any) => {
            if (data.row.package_size) {
              const [length, width, height] = data.row.package_size.split('*')
              return (
                <div class="flex space-x-2">
                  <div>长: {length}mm</div>
                  <div>宽: {width}mm</div>
                  <div>高: {height}mm</div>
                </div>
              )
            }
            return null
          }
        }
      }
    },
    {
      field: 'has_powersource',
      label: t('product.has_powersource'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: t('product.haveValue.1'),
              value: 1
            },
            {
              label: t('product.haveValue.0'),
              value: 0
            }
          ]
        },
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120,
        slots: {
          default: (data: any) => {
            return data.row.has_powersource_name
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.has_powersource_name
          }
        }
      }
    },
    {
      field: 'has_powerline',
      label: t('product.has_powerline'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        formItemProps: {
          rules: [required()]
        },
        componentProps: {
          options: [
            {
              label: t('product.haveValue.1'),
              value: 1
            },
            {
              label: t('product.haveValue.0'),
              value: 0
            }
          ]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120,
        slots: {
          default: (data: any) => {
            return data.row.has_powerline_name
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.has_powerline_name
          }
        }
      }
    },
    {
      field: 'powerline_specs',
      label: t('product.powerline_specs'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input',
        componentProps: {
          maxlength: '50'
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'powerline_standards',
      label: t('product.powerline_standards'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        componentProps: {
          options: schemaConfig.fieldEnum?.value.powerline_standards
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120,
        slots: {
          default: (data: any) => {
            return data.row.powerline_standards_name
          }
        }
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.powerline_standards_name
          }
        }
      }
    },

    {
      field: 'status',
      label: t('product.status'),
      search: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.row.status === 1 ? 'success' : 'warning'}>
                {t(`product.statusValue.${data.row.status}`)}
              </ElTag>
            )
          }
        },
        width: 100
      },
      detail: {
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.status === 1 ? 'success' : 'warning'}>
                {t(`product.statusValue.${data.status}`)}
              </ElTag>
            )
          }
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            { label: '下架', value: 0 },
            { label: '上架', value: 1 }
          ]
        },
        value: 1, // 设置默认选中值为 '1'
        formItemProps: {
          rules: [required()]
        }
      }
    },
    {
      field: 'free_shipping',
      label: t('product.free_shipping'),
      search: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.row.free_shipping === 1 ? 'success' : 'warning'}>
                {t(`product.yes_or_no_value.${data.row.free_shipping}`)}
              </ElTag>
            )
          }
        },
        width: 100
      },
      detail: {
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.free_shipping === 1 ? 'success' : 'warning'}>
                {t(`product.yes_or_no_value.${data.free_shipping}`)}
              </ElTag>
            )
          }
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            { label: '否', value: 0 },
            { label: '是', value: 1 }
          ]
        },
        value: 0, // 设置默认选中值为 '1'
        formItemProps: {
          rules: [required()]
        }
      }
    },
    {
      field: 'apply_rules',
      label: t('product.apply_rules'),
      search: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.row.apply_rules === 1 ? 'success' : 'warning'}>
                {t(`product.yes_or_no_value.${data.row.apply_rules}`)}
              </ElTag>
            )
          }
        },
        width: 100
      },
      detail: {
        slots: {
          default: (data: any) => {
            return (
              <ElTag type={data.apply_rules === 1 ? 'success' : 'warning'}>
                {t(`product.yes_or_no_value.${data.apply_rules}`)}
              </ElTag>
            )
          }
        }
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            { label: '否', value: 0 },
            { label: '是', value: 1 }
          ]
        },
        value: 1, // 设置默认选中值为 '1'
        formItemProps: {
          rules: [required()]
        }
      }
    },
    {
      field: 'min_num',
      label: t('product.min_num'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input',
        componentProps: {
          type: 'number'
        },
        value: 1,
        formItemProps: {
          rules: [required()]
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },
    {
      field: 'is_advance',
      label: t('product.is_advance'),
      search: {
        hidden: true
      },
      form: {
        component: 'Select',
        componentProps: {
          options: [
            { label: '否', value: 0 },
            { label: '是', value: 1 }
          ]
        },
        value: 0 // 设置默认选中值为 '1'
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        slots: {
          default: (data: any) => {
            return data.row.is_advance_text
          }
        },
        width: 140
      },
      detail: {
        slots: {
          default: (data: any) => {
            return data.is_advance_text
          }
        }
      }
    },
    {
      field: 'advance_ratio',
      label: t('product.advance_ratio') + '%',
      search: {
        hidden: true
      },
      form: {
        component: 'Slider',
        value: 50,
        componentProps: {
          min: 20,
          max: 99,
          step: 1,
          showInput: true
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },

    {
      field: 'describe',
      label: t('product.describe'),
      search: {
        hidden: true
      },
      form: {
        component: 'Input',
        componentProps: {
          type: 'textarea'
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150
      }
    },
    {
      field: 'release_date',
      label: t('product.release_date'),
      search: {
        hidden: true
      },
      form: {
        component: 'DatePicker',
        componentProps: {
          type: 'month',
          valueFormat: 'YYYY-MM',
          clearable: true,
          placeholder: '请选择发布月份',
          defaultValue: null
        }
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 150
      }
    },
    {
      field: 'is_merge_product',
      label: t('product.is_merge_product'),
      search: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: t('common.yes_or_no_value.0'),
              value: 0
            },
            {
              label: t('common.yes_or_no_value.1'),
              value: 1
            }
          ],
          clearable: true,
          placeholder: '请选择'
        }
      },
      form: {
        hidden: true
      },
      table: {
        hidden: true
      },
      detail: {
        hidden: true
      }
    },
    {
      field: 'is_have_inventory',
      label: t('product.is_have_inventory'),
      search: {
        component: 'Select',
        componentProps: {
          options: [
            {
              label: t('common.yes_or_no_value.0'),
              value: 0
            },
            {
              label: t('common.yes_or_no_value.1'),
              value: 1
            }
          ],
          clearable: true,
          placeholder: '请选择'
        }
      },
      form: {
        hidden: true
      },
      table: {
        hidden: true
      },
      detail: {
        hidden: true
      }
    },
    {
      field: 'nickname',
      label: t('product.creator'),
      search: {
        hidden: true
      },
      form: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center'
      }
    },
    {
      field: 'create_time',
      label: t('product.create_time'),
      search: {
        hidden: true
      },
      form: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        width: 120
      }
    },

    {
      field: 'action',
      width: (schemaConfig.actionButtonsTemplate?.length || 3) * 60 + 20 + 'px',
      label: t('tableDemo.action'),
      fixed: 'right',
      search: {
        hidden: true
      },
      form: {
        hidden: true
      },
      detail: {
        hidden: true
      },
      table: {
        headerAlign: 'center',
        align: 'center',
        slots: {
          default: (data: any) => {
            return schemaConfig.actionButtonsTemplate?.template(data) ?? null
          }
        }
      }
    }
  ])

  return {
    crudSchemas
  }
}
